//
//  UtilsMacro.h
//  ChengHuiTong
//
//  Created by KiVen on 15/11/2.
//  Copyright © 2015年 张文权. All rights reserved.
//

#ifndef UtilsMacro_h
#define UtilsMacro_h

/**RGB颜色*/
#define ColorWithRGB(r,g,b) [UIColor colorWithRed:r/255. green:g/255. blue:b/255. alpha:1]

#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


#define UIColorFromString(string) [LGToolMethods colorWithHexString:string]

//获取屏幕 宽度、高度
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define iPhone4     ([UIScreen mainScreen].bounds.size.height == 480)
#define iPhone5     ([UIScreen mainScreen].bounds.size.height == 568)
#define iPhone6     ([UIScreen mainScreen].bounds.size.height == 667)
#define iPhone6p    ([UIScreen mainScreen].bounds.size.height == 736)

#define   DEGREES_TO_RADIANS(degrees)  ((M_PI * (degrees))/ 180)


#define NAVBAR_HEIGHT               (44.f + ((SYSTEM_VERSION >= 7) ? STATUSBAR_HEIGHT : 0))
#define TABBAR_HEIGHT               49.f

//#define SCALE                       FULL_WIDTH/320.f
//#define PLUS_SCALE                 FULL_WIDTH/414.f

#define TRIGGER_OFFSET              10.f

#define CONTROL_BUTTON_HEIGHT       44.f
#define STATUSBAR_HEIGHT            20

#define FULL_WIDTH                  [[UIScreen mainScreen] bounds].size.width
#define SYSTEM_VERSION              [[[UIDevice currentDevice] systemVersion] floatValue]
#define FULL_HEIGHT                 (SCREEN_HEIGHT - ((SYSTEM_VERSION >= 7) ? 0 : STATUSBAR_HEIGHT))

#define NAVBAR_HEIGHT               (44.f + ((SYSTEM_VERSION >= 7) ? STATUSBAR_HEIGHT : 0))

#define TABBAR_HEIGHT               49.f

#define APPDelegate ((AppDelegate*)[[UIApplication sharedApplication] delegate])
#define autoScaleW(width) [APPDelegate autoScaleW:width]
#define autoScaleH(height) [APPDelegate autoScaleH:height]

#define leftMargin autoScaleW(15)


#define WeakSelf __weak typeof(self) weakSelf = self;
#define StrongSelf __strong typeof (weakSelf)strongSelf = weakSelf;

#define User  [YPShareAccountInfo shareAccountInfo]
#define TOKEN  User.token


#pragma mark - 本地持久化宏
#define USER_DEFAULT [NSUserDefaults standardUserDefaults]
/// 系统控件默认高度
#define kStatusBarHeight        (20.f)

#define kTopBarHeight           (44.f)
#define kBottomBarHeight        (49.f)

#define kCellDefaultHeight      (44.f)

#define kEnglishKeyboardHeight  (216.f)
#define kChineseKeyboardHeight  (252.f)


/* ****************************************************************************************************************** */
#pragma mark - Funtion Method (宏 方法)

// PNG JPG 图片路径
#define PNGPATH(NAME)           [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:@"png"]
#define JPGPATH(NAME)           [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:@"jpg"]
#define PATH(NAME, EXT)         [[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]

// 加载图片
#define PNGkImg(NAME)          [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"png"]]
#define JPGkImg(NAME)          [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"jpg"]]
#define kImg(NAME, EXT)        [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]]

//定义UIImage对象
#define IMAGE_FILE(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]
#define ImageNamed(name) [UIImage imageNamed:name]

#define URL(url) [NSURL URLWithString:url]
#define String_Connect(str1,Connector,str2) [NSString stringWithFormat:@"%@%@%@",str1,Connector,str2]
#define string(str1,str2) [NSString stringWithFormat:@"%@%@",str1,str2]
#define s_str(str1) [NSString stringWithFormat:@"%@",str1]
#define s_Num(num1) [NSString stringWithFormat:@"%@",num1]
#define s_2_Double(double) [NSString stringWithFormat:@"%.2f",double]
#define s_Integer(num1) [NSString stringWithFormat:@"%ld",num1]
#define s_Sub(str,index) ([str length] > index?[str substringToIndex:index]:str)
// 判断字段时候为空的情况
#define REALSTRING(x) (([(x) isEqual:[NSNull null]]||(x)==nil)? @"":TEXT_STRING(x))
// 转换为字符串
#define TEXT_STRING(x) [NSString stringWithFormat:@"%@",x]

// 字体大小(常规/粗体)
#define BOLDSYSTEMFONT(FONTSIZE)[UIFont boldSystemFontOfSize:FONTSIZE]
#define SYSTEMFONT(FONTSIZE)    [UIFont systemFontOfSize:FONTSIZE]
#define FONT(NAME, FONTSIZE)    [UIFont fontWithName:(NAME) size:(FONTSIZE)]

// 微软雅黑
#define YC_YAHEI_FONT(FONTSIZE) [UIFont fontWithName:@"MicrosoftYaHei" size:(FONTSIZE)]
// 英文 和 数字
#define YC_ENGLISH_FONT(FONTSIZE) [UIFont fontWithName:@"Helvetica Light" size:(FONTSIZE)]

// 颜色(RGB)
#define RGBCOLOR(r, g, b)       [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r, g, b, a)   [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

//number转String
#define IntTranslateStr(int_str) [NSString stringWithFormat:@"%d",int_str];
#define FloatTranslateStr(float_str) [NSString stringWithFormat:@"%.2d",float_str];

// View 圆角和加边框
#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

// View 圆角
#define ViewRadius(View, Radius)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]

#endif /* UtilsMacro_h */
